<?
/**
* Copyright (c) 2002-2007 BioWare Corp.
* http://www.bigdaddymonitor.org
*
* This file is part of the BigDaddy Monitoring
* program. It is free software distributed under
* the terms of the BSD License. It is ditributed
* in the hopes that it will be useful, but
* WITHOUT ANY WARRANTY; without event the implied
* warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE.
*
* The BSD License is available from:
* http://www.opensource.org/licenses/bsd-license.php
**/

if ($_POST["primaryRoleType"])
{
    $nPrimaryRoleTypeID=$_POST["primaryRoleType"];
}
else
{
    $nPrimaryRoleTypeID=$aInfo["primaryRoleTypeID"];
}

?>

<p><a href="<?=$_SERVER["PHP_SELF"];?>?page=listroletyperels">List Role Type Relationships</a></p>

<form method="post" action="<?=$_SERVER["PHP_SELF"];?>">

<p>Choose the RoleType for the Primary RoleID:
<select name="primaryRoleType" size="1" id="app_select">
<?
$aRoleTypes=$RoleAdmin->GetRoleTypes();

for ($i=0; $i<count($aRoleTypes); $i++)
{
    if ($nPrimaryRoleTypeID==$aRoleTypes[$i]["ID"])
    {
	$s=" selected";
    }
    else
    {
	$s="";
    }
    
    ?>
    <option value="<?=$aRoleTypes[$i]["ID"];?>"<?=$s;?>><?=$aRoleTypes[$i]["name"];?></option>
    <?
}
?>
</select>

</p>

<input type="hidden" name="ID" value="<?=$aInfo["ID"];?>">
<input type="hidden" name="page" value="<?=$_REQUEST["page"];?>">
<input type="submit" value="switch role types" id="app_submit" style="float: none">
</form>



<form method="post" action="<?=$_SERVER["PHP_SELF"];?>">
<table border="0" cellpadding="0" cellspacing="0" class="app_table">
<tr class="app_row">
    <td>
	<b>Primary Role ID</b>
    </td>
    <td>

    <?
    if ($nPrimaryRoleTypeID<1 || !$nPrimaryRoleTypeID)
    {
	$nPrimaryRoleTypeID = $aRoleTypes[0]["ID"];
    }
    ?>
    <select name="primaryRoleID" size="1" id="app_select">
    <?
    $aRoles=$RoleAdmin->GetRoleInfoByTypeID($nPrimaryRoleTypeID);

    for ($i=0; $i<count($aRoles); $i++)
    {
	if ($aInfo["primaryRoleID"]==$aRoles[$i]["ID"])
	{
	    $s=" selected";
	}
	else
	{
	    $s="";
	}
	?>
	<option value="<?=$aRoles[$i]["ID"];?>"<?=$s;?>><?=$aRoles[$i]["roleDefinition"];?></option>
	<?
    }
	
	?>
	</select>
    </td>
</tr>
<tr class="app_row">
    <td>
	<b>RoleType</b>
    </td>
    <td>

	    <select name="roleTypeID" size="1" id="app_select">
	    <?
	    $aRoleTypes=$RoleAdmin->GetRoleTypes();
	    for ($i=0; $i<count($aRoleTypes); $i++)
	    {
		if ($aInfo["roleTypeID"]==$aRoleTypes[$i]["ID"])
		{
		    $s=" selected";
		}
		else
		{
		    $s="";
		}
		?>
		<option value="<?=$aRoleTypes[$i]["ID"];?>"<?=$s;?>><?=$aRoleTypes[$i]["name"];?></option>
		<?
	    }
	    
	    ?>
	    </select>

    </td>
</tr>
<tr class="app_row">
    <td>
	<b>Action</b>
    </td>
    <td>
	<?
	if($aInfo["actionID"] > 0)
	{
	    $sMultiSelect = "size='1'";
	}
	else
	{
	    $sMultiSelect = "multiple='yes' size='8'";
	}
	?>
	<select name="actionID[]" <?=$sMultiSelect?> id="app_select">
	<?
	$aAction=$RoleAdmin->GetRoleActions();
	
	for ($i=0; $i<count($aAction); $i++)
	{
	    if ($aInfo["actionID"]==$aAction[$i]["ID"])
	    {
		$s=" selected";
	    }
	    else
	    {
		$s="";
	    }
	    ?>
	    <option value="<?=$aAction[$i]["ID"];?>"<?=$s;?>><?=$aAction[$i]["name"];?> (<?=$aAction[$i]["type"];?>)</option>
	    <?
	}
	
	?>
	</select>
    </td>
</tr>
<tr class="app_row">
    <td>
	<b>Relationship Type</b>
    </td>
    <td>
	<input type="text" name="relationshipType" value="<?=$aInfo["relationshipType"];?>" size="30" id="app_textinput">
    </td>
</tr>
<tr class="app_row">
    <td colspan="2">
	<input type="hidden" name="nRoleTypeRelID" value="<?=$aInfo["ID"];?>">
	<input type="hidden" name="page" value="setroletyperel">
	<input type="submit" name="submit" value="Submit" id="app_submit">
    </td>
</tr>
</table>
</form>


